const Cookies = process.client ? require('js-cookie') : undefined

const getDomain = () => {
  return process.env.VUE_APP_DOMAIN || location.hostname
}
const TokenKey = 'token'
export function getToken() {
  const domain = getDomain()
  return Cookies.get(TokenKey, { domain })
}

export function setToken(token) {
  const domain = getDomain()
  return Cookies.set(TokenKey, token, { domain })
}

export function removeToken() {
  const domain = getDomain()
  Cookies.remove(TokenKey)
  return Cookies.remove(TokenKey, { domain })
}
